package com.jt.assistant.ui

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.speech.tts.TextToSpeech
import androidx.recyclerview.widget.GridLayoutManager
import com.jt.assistant.R
import com.jt.assistant.adapter.HomeAdapter
import com.jt.assistant.bean.HomeBean
import com.jt.assistant.viewmodel.HomeViewModel
import com.yzp.mvvmlibrary.base.BaseActivity
import kotlinx.android.synthetic.main.activity_fast_transfer.*
import kotlinx.android.synthetic.main.activity_home.*

/**
 * 快捷转运
 */
class FastTransferActivity : BaseActivity<HomeViewModel>() {
    private var data = ArrayList<HomeBean>()
    private val mAdapter by lazy {
        HomeAdapter(
            ArrayList<HomeBean>()
        )
    }
    override fun layoutId(): Int = R.layout.activity_fast_transfer

    override fun initView(savedInstanceState: Bundle?) {//
        with(rv_fastTransfer) {
            layoutManager = GridLayoutManager(context, 2)
            adapter = mAdapter
        }
    }

    override fun initData() {
        getHomeData()
        mAdapter.data.addAll(data)
        mAdapter.notifyDataSetChanged()
    }

    override fun initListener() {
        mAdapter.setOnItemClickListener { adapter, view, position ->
            startActivity(Intent(this, mAdapter.data[position].aClass))
        }
    }

    private fun getHomeData() {
        data.add(
            HomeBean(
                "添加出库车辆",
                R.mipmap.menu_item_icon_replenishment_up,
                AddCarActivity::class.java
            )
        )
        data.add(
            HomeBean(
                "生成入库单",
                R.mipmap.menu_item_icon_stock_adjust_up,
                GenerationActivity::class.java
            )
        )
    }

}